/**
  ******************************************************************************
  * @file    RELAY_DRIVER.c
  * @author  Feirui_Joe
  * @version V0.1
  * @date    07/26/2010
  * @brief   ACAD Handling
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/**
  * @brief  INCLUDE FILES.
  */
#ifndef	RELAY_DRIVER_GLOBALS
#define	RELAY_DRIVER_GLOBALS
#include <includes.h>




static void GPIO_RelayOutCfg(void);
static void POR_OutputsSta  (void);

/* Initial Outputs Config */
void RelayOutCfg_Init  (void)
{
	/* Configure RCC clock */
	RCC_RelayOutCfg(ENABLE);
	
	/* Configure GPIO */
	GPIO_RelayOutCfg();
	
	/* POR status */
	POR_OutputsSta();
}



/**
  * @brief  Configures RCC clock for Outputs
  * @param  None
  * @retval None
  */
void RCC_RelayOutCfg(FunctionalState NewState)
{
	uint8_t  i;
	uint32_t RCC_APB2Periph_GPIOx=0;
	
  /* Enable RCC clocks */
  for(i=0;i<RelayOutputsTOTNum;i++)
    RCC_APB2Periph_GPIOx|=RelayOutCfgTable[i].RCC_APB2Periph;
  
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx, NewState);
}


/**
  * @brief  Configures Outputs Control lines.
  * @param  None
  * @retval None
  */
static void GPIO_RelayOutCfg(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  uint8_t i;
  
  /* Configuration Port for InputsExti pin */
  for(i=0;i<RelayOutputsTOTNum;i++)
  {
    GPIO_InitStructure.GPIO_Pin   = RelayOutCfgTable[i].GPIO_Pin;
    GPIO_InitStructure.GPIO_Speed = RelayOutCfgTable[i].GPIO_Speed;
    GPIO_InitStructure.GPIO_Mode  = RelayOutCfgTable[i].GPIO_Mode;
    GPIO_Init(RelayOutCfgTable[i].GPIOx, &GPIO_InitStructure);
  }
}


/**
  * @brief  Outputs Sta After POR.
  * @param  None
  * @retval None
  */
static void POR_OutputsSta  (void)
{
	for(uint8_t i=0;i<RelayOutputsTOTNum;i++)
	  GPIO_ResetBits(RelayOutCfgTable[i].GPIOx ,RelayOutCfgTable[i].GPIO_Pin);
}




/*$PAGE*/#endif	/*	RELAY_DRIVER_GLOBALS	*/
